package LawsonTransformJava.main;

import java.io.File;
import java.io.IOException;
import java.sql.SQLException;

import LawsonTransformJava.pgm.BN531;

public class BN531Main extends ClassMain {

	/**
	 * @author edavis
	 * @param args - All parameters are <b>Required</b>
	 * <div>
	 * [0] - Allow Blank translations
	 * </div>
	 */

	private static final String OUTPUTLOCATION = "z:/conversions/dataload";
	
	public static void main(String[] args) {
		Thread thread1 = null;
		File outFile = new File(OUTPUTLOCATION + "/BNBATCH_EMP_" + getDate());
		File errFile = new File(OUTPUTLOCATION + "/BNBATCH_EMP_ERROR_" + getDate());
		File convRpt = new File(OUTPUTLOCATION + "/BN531TransformationReport_" + getDate() + ".txt");

		try {
			System.out.println("CLASSPATH=" + System.getenv("CLASSPATH"));
			System.out.println("WHERECLAUSE=" + System.getenv("WHERECLAUSE"));
			BN531 objDAO = null;
			if (args.length==0) {
				usage();
			}
			//Output EMPLOYEE records
			//Allow Blank translations where appropriate
			if (args[0].equalsIgnoreCase("true")) {
				objDAO = new BN531(outFile, errFile, convRpt, true);
			}
			else if (args[0].equalsIgnoreCase("false")) {
				objDAO = new BN531(outFile, errFile, convRpt, false);
			}
			
			if (objDAO!=null) {
				thread1 = new Thread(objDAO);
//				objDAO.setWhereClause("WHERE BENEFIT.EMPLOYEE=100060");
				thread1.start();
			} else {
				usage();
			}
		} catch (SQLException sqle) {
			// Could not write properties file
			// Could not create output file
			System.out.println("SQLException: " + sqle);
		}
	}

	private static void usage() {
		System.err.println("Usage - BN531Main true|false");
		System.exit(1);
	}
}
